package jsyf.oa.web.report;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.WrtVisitReportFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2018/1/26 0026.
 */

@Api(value = "客户拜访报表接口", description = "客户拜访报表接口")
@Controller
@RequestMapping("/reportVisit")
public class WrtVisitReportController {
    @Resource
    private WrtVisitReportFacade wrtVisitReportFacade;

    @RequestMapping(value = "/getById.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取regionid",
            notes = "获取regionid",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{userId:'201712161955459C99191A616650E90F'}", dataType = "String", paramType = "body")
    })
    public void getById(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.wrtVisitReportFacade.getById(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getByUserId.json", method = RequestMethod.POST)
    public void getUserByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.wrtVisitReportFacade.getByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }

    @RequestMapping(value = "/getRegionByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理二级报表",
            notes = "区域经理二级报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-01-29',departId:'2018012014454A4EA490E7BA15BE861C',type:'1'}", dataType = "String", paramType = "body")
    })
    public void getRegionByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.wrtVisitReportFacade.getRegionByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }
    @RequestMapping(value = "/getBigRegionByManager.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "公司管理层二级报表",
            notes = "公司管理层二级报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-01-29',companyId:'2017121617464D12B1025EC2259267D2',type:'1'}", dataType = "String", paramType = "body")
    })
    public void getBigRegionByManager(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.wrtVisitReportFacade.getBigRegionByManager(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }
    @RequestMapping(value = "/getRegionByManage.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "公司管理层二级报表",
            notes = "公司管理层二级报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-01-29',companyId:'2017121617464D12B1025EC2259267D2',type:'1'}", dataType = "String", paramType = "body")
    })
    public void getRegionByManage(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.wrtVisitReportFacade.getRegionByManage(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getRegionByChart.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "集团管理层柱状图",
            notes = "集团管理层柱状图",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-01-29',companyId:''}", dataType = "String", paramType = "body")
    })
    public void getRegionByChart(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.wrtVisitReportFacade.getRegionByChart(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }

    @RequestMapping(value = "/getRegionByManageChart.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "公司管理层柱状图",
            notes = "公司管理层柱状图",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-01-29',companyId:''}", dataType = "String", paramType = "body")
    })
    public void getRegionByManageChart(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.wrtVisitReportFacade.getRegionByManageChart(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }

    @RequestMapping(value = "/getRegionInfo.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "集团管理层目标完成",
            notes = "集团管理层目标完成",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-01-29',companyId:''}", dataType = "String", paramType = "body")
    })
    public void getRegionInfo(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.wrtVisitReportFacade.getRegionInfo(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }

    @RequestMapping(value = "/getCompanyByManage.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "集团管理层报表",
            notes = "集团管理层报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{type:'1',dateTime:'2018-01-29'}", dataType = "String", paramType = "body")
    })
    public void getCompanyByManage(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.wrtVisitReportFacade.getCompanyByManage(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getCompanyByChart.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "集团管理层柱状图",
            notes = "集团管理层柱状图",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-01-29'}", dataType = "String", paramType = "body")
    })
    public void getCompanyByChart(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.wrtVisitReportFacade.getCompanyByChart(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }

    @RequestMapping(value = "/getPeopleByUserId.json", method = RequestMethod.POST)
    public void getPeopleByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.wrtVisitReportFacade.getPeopleByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(records));
    }
}
